﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using DevExpress.UserSkins;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using BCL.BaseLib.Basics;
using BCL.BaseLib;
namespace BCL.Main
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            System.IO.FileSystemWatcher f = new System.IO.FileSystemWatcher();
            
            //System.Diagnostics.Process.GetProcessesByName("");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BonusSkins.Register();
            SkinManager.EnableFormSkins();
            //UserLookAndFeel.Default.SetSkinStyle("Office 2010 Blue");//"Office 2013"

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            ////处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //System.Drawing.Image image = System.Drawing.Bitmap.FromFile("image\\1.png");
            //System.Drawing.Image image2 = System.Drawing.Bitmap.FromFile("image\\2.png");
            //System.Drawing.Image image3 = System.Drawing.Bitmap.FromFile("image\\3.png");


            //List<FunctionEntity> fes = new List<FunctionEntity>();
            //FunctionEntity fe = new FunctionEntity { AppCode = "001", AppId = "001", Title = "检查化验", ItemType = FunctionItemType.Group };
            //fe.Items = new List<FunctionEntity>
            //{
            //    new FunctionEntity { AppCode = "00102", AppId = "00102", Title = "待检查", Index=true, ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "XiaonuanPMS.dll", ClassFillName = "XiaonuanPMS.FormTestNew" }, Image = image2 },
            //    //new FunctionEntity { AppCode = "00201", AppId = "00201", Title = "检查", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.FormTestNew" }, Image = image2 },
            //    new FunctionEntity { AppCode = "00101", AppId = "00101", Title = "已完成", ItemType = FunctionItemType.Item, FunctionType = FunctionType.Control, ClassInfo = new ClassInfo { DLLName = "View.dll", ClassFillName = "DevicesView.UserControlRelust" }, Image = image },
            //};
            //fes.Add(fe);

            Form1 form1 = new Form1();
            form1.Functiones = null;
            Application.Run(form1);
            //Application.Run(new Form1());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            //MessageBox.Show(e.Exception.Message);
            //ClientCommon.Logs.Log(e.Exception.Message, e.Exception.StackTrace);
            BCLApplication.log.Write(e.Exception.Message);
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            //ClientCommon.Logs.Log(e.ExceptionObject.ToString());
            BCLApplication.log.Write(e.ExceptionObject.ToString());
        }
    }
}
